package instance

import (
	"errors"
	"fmt"

	yaml "gopkg.in/yaml.v2"
)

type DdnsInstanceBase struct {
	ID     int    `yaml:"id"`
	Type   string `yaml:"type"`
	Enable bool   `yaml:"enable"`
}

func (d *DdnsInstanceBase) Parse(content []byte) error {
	err := yaml.Unmarshal(content, d)

	return err
}

func (d *DdnsInstanceBase) String() string {
	return fmt.Sprintf("Type: %s", d.Type)
}

func (d *DdnsInstanceBase) Run() error {
	if !d.Enable {
		return errors.New("not enabled")
	}

	return nil
}
